package com.zhc.dejingapi.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhc.dejingapi.entity.QingProductionorderDetialEntity;
import com.zhc.dejingapi.entity.QingProductionorderEntity;
import com.zhc.dejingapi.entity.vo.QingProductionOrderVo;
import com.zhc.dejingapi.mapper.QingProductionorderDetialMapper;
import com.zhc.dejingapi.mapper.QingProductionorderMapper;
import com.zhc.dejingapi.service.QingProductionorderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhc
 * @since 2024-10-21
 */
@Service
public class QingProductionorderServiceImpl extends ServiceImpl<QingProductionorderMapper, QingProductionorderEntity> implements QingProductionorderService {

    @Resource
    private QingProductionorderMapper qingProductionorderMapper;

    @Resource
    private QingProductionorderDetialMapper qingProductionorderDetialMapper;
    @Override
    public void getProductionOrder(QingProductionOrderVo qingProductionOrderVo) {
        QingProductionorderEntity qingProductionorderEntity = new QingProductionorderEntity();
        BeanUtil.copyProperties(qingProductionOrderVo,qingProductionorderEntity);
        int insert = qingProductionorderMapper.insert(qingProductionorderEntity);
        if(insert > 0){
            for (QingProductionorderDetialEntity qingProductionorderDetialEntity: qingProductionOrderVo.getQingProductionorderDetialEntityList()){
                qingProductionorderDetialEntity.setPoId(qingProductionorderEntity.getMainId());
                int insert1 = qingProductionorderDetialMapper.insert(qingProductionorderDetialEntity);
            }
        }
    }
}
